import hyRequest from "../index"
import type { IAccount, IDataType, ILoginResult } from "./types"

enum LoginApi {
  AccountLogin = '/login',
  UserInfo = '/users/',
  UserMenus = '/role/'
}

// 登录
export function accountLoginRequest(account: IAccount) {
  return hyRequest.post<IDataType<ILoginResult>>({
    url: LoginApi.AccountLogin,
    data: account
  })
}

// 获取用户信息
export function getUserInfo(id: number) {
  return hyRequest.get({
    url: LoginApi.UserInfo + id,
  })
}

// 获取用户的菜单
export function getUserMenus(id: number) {
  return hyRequest.get<IDataType>({
    url: LoginApi.UserMenus + id + '/menu'
  })
}